package character;

import com.jme3.math.FastMath;
import effect.Effect;
import modifier.character.CharacterModifier;
import modifier.character.CharacterModifierActionSpeed;
import game.DataStore;
import java.util.HashMap;
import java.util.Map;

public class CharacterStats {
    protected MyCharacter character;
    protected int maxHitPoints, sightRange, moveSpeed;
    protected int strength, dexterity, intelligence;
    protected Map<Integer, Effect> abilities = new HashMap<Integer, Effect>();

    @Deprecated
    protected CharacterStats() {}

    public CharacterStats(MyCharacter character) {
	this.character = character;
    }

    public int getMaxHitPoints() {
	return maxHitPoints;
    }
    public void setMaxHitPoints(int maxHitPoints) {
	this.maxHitPoints = maxHitPoints;
    }
    public int getSightRange() {
	return sightRange;
    }
    public void setSightRange(int sightRange) {
	this.sightRange = sightRange;
    }
    public void setMoveSpeed(int moveSpeed) {
	this.moveSpeed = moveSpeed;
    }
    public int getMoveSpeedNoModifier() {
        return moveSpeed;
    }
    public int getMoveSpeedWithModifier() {
	return Math.round(FastMath.ceil(moveSpeed * getActionSpeedModifier()));
    }
    public int getDiagonalMoveSpeedNoModifier() {
        return Math.round(moveSpeed * DataStore.DIAGONAL_MOVE_RATIO);
    }
    public int getDiagonalMoveSpeedWithModifier() {
        return Math.round(getMoveSpeedWithModifier() * DataStore.DIAGONAL_MOVE_RATIO);
    }
    /** The multiplier that should be applied to all actions (from effects such as haste, etc.) */
    public float getActionSpeedModifier() {
        for(CharacterModifier modifier : character.getCharacterModifiers()) {
            if(modifier instanceof CharacterModifierActionSpeed)
                return ((CharacterModifierActionSpeed)modifier).getActionSpeedMultiplier();
        }
        return 1;
    }
    public int getStrength() {
        return strength;
    }
    public void setStrength(int strength) {
        this.strength = strength;
    }
    public int getDexterity() {
        return dexterity;
    }
    public void setDexterity(int dexterity) {
        this.dexterity = dexterity;
    }
    public int getIntelligence() {
        return intelligence;
    }
    public void setIntelligence(int intelligence) {
        this.intelligence = intelligence;
    }
    public Map<Integer, Effect> getAbilities() {
        return abilities;
    }
    public void addAbility(Integer number, Effect effect) {
        abilities.put(number, effect);
    }
    public Effect getAbility(Integer effectNum) {
        return abilities.get(effectNum);
    }
}
